/* This class represents the custom buttons we use in out guis
 * 
 */

package gui.utilities;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

public class MyButton extends JPanel{

	private static final long serialVersionUID = 1192054304794432043L;
	JLabel normal; //the picture used for the button normally
	JLabel hover; //the picture used for the button when the mouse is hovering on top of it
	private Dimension size; //the dimensions of the button
	MouseAdapter action; //the MouseAdapter for the default actions
	
	//4 param constructor that creates and sets up the button
	public MyButton(String n, String o, int w, int h) {
		
		normal = new JLabel(new ImageIcon(n));
		hover = new JLabel(new ImageIcon(o));
		size = new Dimension(h, w);
		
		this.setLayout(new GridLayout(1,1));
		
		this.setMaximumSize(size);
		this.add(normal);
		
		action = new MouseAdapter(){
			
				public void mouseEntered(MouseEvent e){
				
				remove(normal);
				add(hover);
				repaint();
				revalidate();
			}//mouseEntered
			
			
			public void mouseExited(MouseEvent e){
				
				remove(hover);
				add(normal);
				repaint();
				revalidate();
			}//mouseExited
		};
		
		//to activate the mouse actions
		this.addMouseListener(action);
	}//String String int int constructor to set up the button
	
}//Button